<script setup>
import { ref, watch } from 'vue';
let text=ref("")

watch(()=>text.value,(newValue,oldValue)=>{
    console.log("oldValue",oldValue)
    console.log("newValue",newValue)

    console.log("newValue".includes("我"))

    if(newValue.includes("我")){
        let newtext=newValue.substring(0,newValue.length - 1);
        console.log(newtext)
        text.value=newtext
        alert("勿作死");
    }
})
</script>

<template>
    <div>
         <input type="text" placeholder="请输入监控的文本，不能有‘我’" v-model="text">
    </div>
</template>

<style scoped>
</style>